<!-- \netmouse\app\src\main\assets-->
<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <title>Java 代码高亮显示</title>
  <style>
    body {
      font-family: 'Consolas', 'Courier New', monospace;
      background-color: #2B2B2B;
      color: #F8F8F8;
    }

    pre {
      background-color: #1E1E1E;
      color: #F8F8F8;
      padding: 10px;
      border-radius: 5px;
    }

   .comment {
      color: #6A6A6A;
    }

   .keyword {
      color: #CDA869;
    }

   .string {
      color: #A6E22E;
    }

   .number {
      color: #AE81FF;
    }

   .operator {
      color: #F92672;
    }

   .delimiter {
      color: #F8F8F2;
    }

   .identifier {
      color: #A9B7C6;
    }
  </style>
</head>

<body>

  <pre>
<code class="java">
<span class="keyword">package</span> com.example.myapplication;

<span class="keyword">import</span> android.annotation.SuppressLint;
<span class="keyword">import</span> android.app.Activity;
<span class="keyword">import</span> android.content.Context;
<span class="keyword">import</span> android.content.SharedPreferences;
<span class="keyword">import</span> android.os.Bundle;
<span class="keyword">import</span> android.view.Gravity;
<span class="keyword">import</span> android.view.LayoutInflater;
<span class="keyword">import</span> android.view.View;
<span class="keyword">import</span> android.view.ViewGroup;
<span class="keyword">import</span> android.widget.EditText;
<span class="keyword">import</span> android.widget.PopupWindow;
<span class="keyword">import</span> android.widget.Toast;

<span class="keyword">import</span> java.io.BufferedReader;
<span class="keyword">import</span> java.io.IOException;
<span class="keyword">import</span> java.io.InputStreamReader;
<span class="keyword">import</span> java.io.PrintWriter;
<span class="keyword">import</span> java.net.Socket;

<span class="keyword">public</span> <span class="class"><span class="identifier">MainActivity</span></span> <span class="keyword">extends</span> Activity {

    <span class="keyword">String</span> ipp<span class="delimiter">=</span><span class="string">"192.168.1.134"</span>;
    <span class="keyword">int</span> portt<span class="delimiter">=</span><span class="number">8081</span>;

    <span class="keyword">int</span> textsize<span class="delimiter">=</span><span class="number">10</span>;


    <span class="annotation">@SuppressLint</span>(<span class="string">"ClickableViewAccessibility"</span>)
    <span class="keyword">@Override</span>
    <span class="keyword">protected</span> <span class="keyword">void</span> onCreate(Bundle savedInstanceState) {
        <span class="keyword">super</span>.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        //
        EditText cfmdg=findViewById(R.id.ip);
        SharedPreferences sharedPreferencesp = getSharedPreferences("netkey", Context.MODE_PRIVATE);
        String netkey_ip = sharedPreferencesp.getString("ip", "");// 从SharedPreferences中获取保存的账号密码
        ipp=netkey_ip;
        cfmdg.setText(netkey_ip);
    }

    <span class="keyword">public</span> <span class="keyword">void</span> ok(View view) {
        EditText cmd=findViewById(R.id.cmd);
        String cmd_c=cmd.getText().toString();
        new Thread(new Runnable() {
            @Override
            public void run() {
                String host = ipp; // 服务器的IP地址
                int port = portt; // 服务器的端口号
                try (Socket socket = new Socket(host, port);
                     PrintWriter writer = new PrintWriter(socket.getOutputStream(), true);
                     BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream()))) {
                    // 发送字符串"000000"到服务器
                    writer.println("system"+cmd_c);
                    // 读取服务器响应的数据
                    String data = reader.readLine();
                    if (data!= null) {
                        System.out.println("Received data from server: " + data);
                    }
                } catch (IOException e) {
                    System.err.println("Error in the client>>>>>>>>>>>>>>> : " + e.getMessage());
                    e.printStackTrace();
                }

            }
        }).start();
    }


    <span class="keyword">public</span> <span class="keyword">void</span> add(View view) {
        EditText cmd=findViewById(R.id.cmd);
        textsize=textsize+1;
        cmd.setTextSize(textsize);
    }

    <span class="keyword">public</span> <span class="keyword">void</span> remo(View view) {
        EditText cmd=findViewById(R.id.cmd);
        textsize=textsize-1;
        cmd.setTextSize(textsize);
    }

    <span class="keyword">public</span> <span class="keyword">void</span> clear(View view) {
        EditText cmd=findViewById(R.id.cmd);
        cmd.setText("");
    }

    <span class="keyword">public</span> <span class="keyword">void</span> exit(View view) {
        finish();
    }

    <span class="keyword">public</span> <span class="keyword">void</span> save_ip(View view) {
        EditText cfmd=findViewById(R.id.ip);
        String ipc =cfmd.getText().toString();
        ipp=ipc;//


        SharedPreferences sharedPreferences = getSharedPreferences("netkey", Context.MODE_PRIVATE);
        SharedPreferences.Editor editor_ip = sharedPreferences.edit();
        editor_ip.putString("ip", ipc);// 将账号密码保存到SharedPreferences中
        editor_ip.apply();


        Toast.makeText(MainActivity.this, "已保存IP:"+ipc, Toast.LENGTH_SHORT).show();
    }

    <span class="keyword">public</span> <span class="keyword">void</span> net(String commof) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                //
                String host = ipp; // 服务器的IP地址
                int port = portt; // 服务器的端口号

                try (Socket socket = new Socket(host, port);
                     PrintWriter writer = new PrintWriter(socket.getOutputStream(), true);
                     BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream()))) {

                    // 发送字符串"000000"到服务器
                    writer.println(commof);

                    // 读取服务器响应的数据
                    String data = reader.readLine();
                    if (data!= null) {
                        System.out.println("Received data from server: " + data);
                    }

                } catch (IOException e) {
                    System.err.println("Error in the client>>>>>>>>>>>>>>> : " + e.getMessage());
                    e.printStackTrace();
                }

            }
        }).start();
    }


    <span class="keyword">public</span> <span class="keyword">void</span> task(View view) {
        net("taskmgr");
    }

    <span class="keyword">public</span> <span class="keyword">void</span> reboot(View view) {
        net("reboot");
    }

    <span class="keyword">public</span> <span class="keyword">void</span> shutdown(View view) {
        net("shutdown");
    }

    <span class="keyword">public</span> <span class="keyword">void</span> shuangji(View view) {
        net("shuangji");
    }

    <span class="keyword">public</span> <span class="keyword">void</span> danji(View view) {
        net("danji");
    }

    <span class="keyword">public</span> <span class="keyword">void</span> mouse_l(View view) {
        net(" mouse_l");
    }

    <span class="keyword">public</span> <span class="keyword">void</span> mouse_r(View view) {
        net("mouse_r");
    }

    <span class="keyword">public</span> <span class="keyword">void</span> browser(View view) {
        net("browser");
    }

    <span class="keyword">public</span> <span class="keyword">void</span> key(View view) {
        LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
        @SuppressLint("InflateParams") View popupView = inflater.inflate(R.layout.key, null);
        PopupWindow popupWindow = new PopupWindow(popupView, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, true);
        popupWindow.showAtLocation(view, Gravity.CENTER, 0, 0);
    }

    <span class="keyword">public</span> <span class="keyword">void</span> up(View view) {
        net("up");
    }

    <span class="keyword">public</span> <span class="keyword">void</span> left(View view) {
        net("left");
    }

    <span class="keyword">public</span> <span class="keyword">void</span> right(View view) {
        net("right");
    }

    <span class="keyword">public</span> <span class="keyword">void</span> down(View view) {
        net("down");
    }

    <span class="keyword">public</span> <span class="keyword">void</span> unable(View view) {
        net("unable");
    }
}
</code>
</pre>

</body>

</html>
